package com.wdb.user.service;

import com.wdb.common.configurer.authority.AuthorityResponse;
import com.wdb.common.configurer.subject.SubjectTarget;
import com.wdb.common.configurer.subject.Subjected;
import com.wdb.domain.user.entity.UserInfo;
import com.wdb.domain.user.entity.UserInfoPin;
import com.wdb.domain.user.request.UserPinLoginRequest;
import com.wdb.user.fallback.UserInfoPinFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@FeignClient(name = "com-wdb-user",fallback = UserInfoPinFallback.class)
public interface UserInfoService {

    @GetMapping("/user/info")
    @Subjected(target = SubjectTarget.DOCTOR)
    @ResponseStatus(HttpStatus.OK)
    Map<String,Object> findUserInfo(@RequestParam("id")Long id);

    @PostMapping("/user/info")
    @Subjected(target = SubjectTarget.USER)
    @ResponseStatus(HttpStatus.CREATED)
    Map<String,Object> saveUserInfo(@RequestBody UserInfo userInfo);

    @PostMapping("/auth/login")
    @Subjected(target = SubjectTarget.INVOKE)
    @ResponseStatus(HttpStatus.CREATED)
    AuthorityResponse login(@RequestBody UserPinLoginRequest request);

    @PostMapping("/auth/register")
    @Subjected(target = SubjectTarget.INVOKE)
    @ResponseStatus(HttpStatus.CREATED)
    UserInfoPin register(@RequestBody UserPinLoginRequest request);

}